<?php
include(getabspath("include/sales_order_items_settings.php"));

function DisplayMasterTableInfo_sales_order_items($params)
{
	$detailtable=$params["detailtable"];
	$keys=$params["keys"];
	global $conn,$strTableName;
	$xt = new Xtempl();
	
	$oldTableName=$strTableName;
	$strTableName="sales_order_items";

//$strSQL = "SELECT id,   sales_order_id,   item_no,   product_id,   property_id,   size_system_id,   unit_price,   total_quantity,   size_breakup_id,   delivery_date,   status  FROM sales_order_items ";

$sqlHead="SELECT id,   sales_order_id,   item_no,   product_id,   property_id,   size_system_id,   unit_price,   total_quantity,   size_breakup_id,   delivery_date,   status";
$sqlFrom="FROM sales_order_items";
$sqlWhere="";
$sqlTail="";

$where="";

if($detailtable=="sales_order_size_breakup")
{
		$where.= GetFullFieldName("sales_order_id")."=".make_db_value("sales_order_id",$keys[1-1]);
		$where.=" and ";
	$where.= GetFullFieldName("id")."=".make_db_value("id",$keys[2-1]);
}
if(!$where)
{
	$strTableName=$oldTableName;
	return;
}
	$str = SecuritySQL("Export");
	if(strlen($str))
		$where.=" and ".$str;
	
	$strWhere=whereAdd($sqlWhere,$where);
	if(strlen($strWhere))
		$strWhere=" where ".$strWhere." ";
	$strSQL= $sqlHead.' '.$sqlFrom.$strWhere.$sqlTail;

//	$strSQL=AddWhere($strSQL,$where);

	LogInfo($strSQL);
	$rs=db_query($strSQL,$conn);
	$data=db_fetch_array($rs);
	if(!$data)
	{
		$strTableName=$oldTableName;
		return;
	}
	$keylink="";
	$keylink.="&key1=".htmlspecialchars(rawurlencode(@$data["id"]));
	


//	id - 
			$value="";
				$value = ProcessLargeText(GetData($data,"id", ""),"field=id".$keylink,"",MODE_PRINT);
			$xt->assign("id_mastervalue",$value);

//	sales_order_id - 
			$value="";
				$value = ProcessLargeText(GetData($data,"sales_order_id", ""),"field=sales%5Forder%5Fid".$keylink,"",MODE_PRINT);
			$xt->assign("sales_order_id_mastervalue",$value);

//	item_no - 
			$value="";
				$value = ProcessLargeText(GetData($data,"item_no", ""),"field=item%5Fno".$keylink,"",MODE_PRINT);
			$xt->assign("item_no_mastervalue",$value);

//	product_id - 
			$value="";
				$value=DisplayLookupWizard("product_id",$data["product_id"],$data,$keylink,MODE_PRINT);
			$xt->assign("product_id_mastervalue",$value);

//	property_id - 
			$value="";
				$value=DisplayLookupWizard("property_id",$data["property_id"],$data,$keylink,MODE_PRINT);
			$xt->assign("property_id_mastervalue",$value);

//	size_system_id - 
			$value="";
				$value=DisplayLookupWizard("size_system_id",$data["size_system_id"],$data,$keylink,MODE_PRINT);
			$xt->assign("size_system_id_mastervalue",$value);

//	unit_price - Number
			$value="";
				$value = ProcessLargeText(GetData($data,"unit_price", "Number"),"field=unit%5Fprice".$keylink,"",MODE_PRINT);
			$xt->assign("unit_price_mastervalue",$value);

//	total_quantity - Number
			$value="";
				$value = ProcessLargeText(GetData($data,"total_quantity", "Number"),"field=total%5Fquantity".$keylink,"",MODE_PRINT);
			$xt->assign("total_quantity_mastervalue",$value);

//	size_breakup_id - 
			$value="";
				$value = ProcessLargeText(GetData($data,"size_breakup_id", ""),"field=size%5Fbreakup%5Fid".$keylink,"",MODE_PRINT);
			$xt->assign("size_breakup_id_mastervalue",$value);

//	delivery_date - Short Date
			$value="";
				$value = ProcessLargeText(GetData($data,"delivery_date", "Short Date"),"field=delivery%5Fdate".$keylink,"",MODE_PRINT);
			$xt->assign("delivery_date_mastervalue",$value);
	$xt->display("sales_order_items_masterprint.htm");
	$strTableName=$oldTableName;

}

?>